#include "common.h"
/*Why I not treat the following two variables as the global variable,
  Just because the storage device vary.*/
 CHAR  ataserialnumber[21];
 U4B   atamaxsectors;

VOID FSDriver()
{
   /*Open the cascade and ata interrupt*/
   ActivateATA();
   SIGNAL signal;
   MESSAGE message;
   while(1)
   {
    if(ReceiveMessage(&message)!=ARTIST_ERROR_OK)continue;
     switch(message.type)
     {
       case FSDRIVER_WHOIAM:
       {
          Print("FSDriver begin...\n");
          ATAPrimaryIdentify(ataserialnumber,&atamaxsectors);
          Print("HD Serial Number:%#0Cs\n",ataserialnumber);
          Print("Sectors:0x%#0cX,the HD Size:0x%#0cXMB\n",atamaxsectors,atamaxsectors/2/1024);  
          break;
       }
       case FSDRIVER_WRITE:
       {
         ATAWritePrimarySectors((message.value0), 
                                (message.value1),
                             (PU1B)(message.value2));
         signal.returnvalue=0;
         signal.dt=message.sourcepid;
         signal.signal=FSDRIVER_WRITE;
         NotifyWaited(&signal);
         break;
       }
       case FSDRIVER_READ:
       {
         //  Print("aeqqqqqqqqqqqqqqqqq%X\n",message.value2);
           ATAReadPrimarySectors((message.value0), 
                                (message.value1),
                             (PU1B)(message.value2));
//Print("ssssssssafsaaAAAAAAAAAAAAAAAAssssssssssssssss%#0cX\n",message.sourcepid);
         signal.returnvalue=0;
         signal.dt=message.sourcepid;
         signal.signal=FSDRIVER_READ;
         NotifyWaited(&signal);         
           break;
       }
     }
   }
}
